package com.lanqiao.guimei.commons;

import com.lanqiao.guimei.vo.*;
import org.apache.commons.dbutils.handlers.AbstractListHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @Author:沈林玉
 * @date:2019/8/18 16:15
 * @Description:
 */
public class SaleProdListHandler extends AbstractListHandler<SaleProd> {

    @Override
    protected SaleProd handleRow(ResultSet rs) throws SQLException {
        SaleProd saleProd = new SaleProd();

        Product product = new Product();
        GuimeiUsers guimeiUsers = new GuimeiUsers();
        Stock stock = new Stock();

        saleProd.setProduct(product);
        saleProd.setGuimeiUsers(guimeiUsers);
        saleProd.setStock(stock);
/*
                   s.saler_id   salerId,
                   s.stk_id     stkId,
                   s.real_price realPrice,
* */

            int id = rs.getInt("id");
            String prodNo = rs.getString("prodNo");
            String prodName = rs.getString("prodName");
            String loginName = rs.getString("loginName");
            String stkName = rs.getString("stkName");
            Double realPrice = rs.getDouble("realPrice");
            Integer carriage = rs.getInt("carriage");
            Date starTime = rs.getDate("starTime");
            Date endTime = rs.getDate("endTime");
            String prodSkin = rs.getString("prodSkin");
            String location = rs.getString("location");
            Integer status = rs.getInt("status");

            saleProd.setId(id);
            saleProd.setProdNo(prodNo);
            product.setProdNo(prodNo);
            product.setProdName(prodName);
            guimeiUsers.setLoginName(loginName);
            stock.setStkName(stkName);
            saleProd.setRealPrice(realPrice);
            saleProd.setCarriage(carriage);
            saleProd.setStarTime(starTime);
            saleProd.setEndTime(endTime);
            saleProd.setProdSkin(prodSkin);
            saleProd.setLocation(location);
            saleProd.setStatus(status);

        return saleProd;
    }
}
